/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
function tempLast24Hours() {
    var dashboard = new google.visualization.Dashboard(
       document.getElementById('dashboard'));
   var control = new google.visualization.ControlWrapper({
     'controlType': 'ChartRangeFilter',
     'containerId': 'control',
     'options': {
         'filterColumnIndex': 0,
       'ui': {
         'chartType': 'LineChart',
         'chartView': {
           'columns': [0, 1,2]
         }
       }
      }
   });       
        var datatbl = new google.visualization.DataTable();
        //get the data from the file and load it into the google datatable
    $.getJSON('/fetchData.php?data={Fields:Date,Temp,FeelsLike,Pressure|Sort:Date,Ascending|Interval:6}', function(data) {

             var noElements = data.length;
             datatbl.addColumn('datetime', 'Date');
             datatbl.addColumn('number', 'Temp');
             datatbl.addColumn('number', 'Dew Point');
             datatbl.addColumn('number', 'Pressure');
             datatbl.addRows(noElements);
        
        //Put the data into the datatable
        $.each(data, function(i, v) {
            // set the values for both the name and the population
            
            datatbl.setValue(i, 0, new Date(v.Date));
            datatbl.setValue(i, 1, v.Temp);
            datatbl.setValue(i, 2, v.FeelsLike);
            datatbl.setValue(i, 3, v.Pressure);
        });

 var chart = new google.visualization.ChartWrapper({
     'chartType': 'LineChart',
      'containerId': 'graph',
      'options' : {
          'chartArea': {'height': '80%', 'width': '85%'},
          series:{2:{targetAxisIndex:1}}, vAxes:{1:{title:'Pressure',textStyle:{color: 'orange'}}},
          'title': 'Temperature and Pressure'
      }
     
});
    //declare the chart (which is a table) and draw it 
//    var chart = new google.visualization.LineChart(document.getElementById('graph'));
//      chart.draw(datatbl, options);
 //control.draw(datatbl);
  dashboard.bind(control, chart);
   dashboard.draw(datatbl);
      });
}

